package educrypt.gui.components;

import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionListener;
import javax.swing.JToggleButton;

import educrypt.gui.view.GoToView;
import educrypt.i18n.Messages;

class GoToPanel extends EducryptPanel implements GoToView {

	private static final long serialVersionUID = -3809630865423513859L;

	private JToggleButton btnCryptanalysis, btnAnalysis, btnDatabase, btnAbout;
	private JToggleButton btnCiphers;

	private ButtonGroup groupBtnAction;

	public GoToPanel() {
		this.setSize(110, 600);
		this.setPreferredSize(this.getSize());

		this.setLayout(new GridLayout(0, 1, 0, 0));

		btnCiphers = new JToggleButton(Messages.getString("guiCipher"));
		add(btnCiphers);

		btnCryptanalysis = new JToggleButton(
				Messages.getString("guiCryptanalysis"));
		add(btnCryptanalysis);

		btnAnalysis = new JToggleButton(Messages.getString("guiAnalysis"));
		add(btnAnalysis);

		btnDatabase = new JToggleButton(Messages.getString("guiDatabase"));
		add(btnDatabase);

		btnAbout = new JToggleButton(Messages.getString("guiAbout"));
		add(btnAbout);

		groupBtnAction = new ButtonGroup();
		groupBtnAction.add(btnAnalysis);
		groupBtnAction.add(btnCiphers);
		groupBtnAction.add(btnCryptanalysis);
		groupBtnAction.add(btnDatabase);
		groupBtnAction.add(btnAbout);

	}

	@Override
	public void addListener(ActionListener ctr) {
		this.btnCiphers.addActionListener(ctr);
		this.btnCiphers.setActionCommand(GoToView.GOTO_CIPHERS);
		this.btnCryptanalysis.addActionListener(ctr);
		this.btnCryptanalysis.setActionCommand(GoToView.GOTO_CRYPTANALYSIS);
		this.btnAnalysis.addActionListener(ctr);
		this.btnAnalysis.setActionCommand(GoToView.GOTO_ANALYSIS);
		this.btnDatabase.addActionListener(ctr);
		this.btnDatabase.setActionCommand(GoToView.GOTO_DATABASE);
		this.btnAbout.addActionListener(ctr);
		this.btnAbout.setActionCommand(GoToView.GOTO_ABOUT);
	}
}
